package com.itheima.d2_upd1;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.util.Scanner;

public class Client {
    public static void main(String[] args)throws Exception {
        DatagramSocket socket = new DatagramSocket();
        Scanner sc =new Scanner(System.in);
        while (true) {
            System.out.println("请输入：");
            String rs = sc.nextLine();
            if("exit".equals(rs)){
                System.out.println("退出成功");
                socket.close();
                break;
            }

            byte[] bytes = rs.getBytes();
            DatagramPacket packet = new DatagramPacket(bytes, bytes.length
                    , InetAddress.getByName("127.0.0.1"), 8888);
            socket.send(packet);
        }
        System.out.println("发送完毕");



    }
}
